package com.ruoyi.system.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author ffc
 * @version 1.0
 * @description: TODO
 * @className: RabbitmqConfig
 * @date 2024/8/26 21:48
 */

@Configuration
public class RabbitMQConfig {
    @Bean
    public Exchange declareTopicExchange(){
        return ExchangeBuilder.topicExchange("topicExchange")
                .durable(true).build();
    }
    @Bean
    public Queue declareUserQueue(){
        return QueueBuilder.durable("user_queue").build();
    }
    @Bean
    public Queue declareBusinessQueue(){
        return QueueBuilder.durable("business_queue").build();
    }
    @Bean
    public Binding declareBindingUserQueue(){
        return BindingBuilder.bind(declareUserQueue()).to(declareTopicExchange())
                .with("user")
                .noargs();
    }
    @Bean
    public Binding declareBinding2(){
        return BindingBuilder.bind(declareBusinessQueue()).to(declareTopicExchange())
                .with("business").noargs();
    }
}
